//	 ID : pallab81
// 	PROG : 725
// 	LANG : C++
// 	2011-10-13-21.10.03 Thursday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}

// generate all pair of five digit number

inline bool isSeen(int mask, int id){
    return ( mask&(1<<id) )==0 ? 0 : 1;
}
inline int Select(int mask, int id){
    return ( mask|(1<<id) ) ;
}

string feed="";
int N;
vector<int> vt;
int total;
inline void go(int mask, int len, int num){
    if( len==0 ){
        vt.pb( num );
        return ;
    }
    for(int i=0;i<=9;++i){
        if( isSeen(mask,i)==false ){
            int num_ = num*10+i;
            go( Select(mask,i), len-1  , num_ );
        }
    }
return ;
}
inline bool good(int num1, int num2){
    char buff1[10],buff2[10];
    sprintf(buff1,"%05d",num1);
    sprintf(buff2,"%05d",num2);
    //cout<<buff1<<" "<<buff2<<"\n";
    for(int i=0;i<5;++i){
        for(int j=0;j<5;++j){
            if( buff1[i]==buff2[j] )return false;
        }
    }

    return binary_search(vt.begin(),vt.end(), num2);
}
inline void doit(){
    bool flag=0;
    cout<<feed;
    feed="\n";
    for(int i=0 ; i<total; ++i ){
        if( (vt[i]%N) ==0 ){
            int var = vt[i]/N;
            if( good(vt[i],var) ){
                printf("%05d / %05d = %d\n",vt[i], var , N );
                flag=1;
            }
        }
    }
    if( !flag )
        printf("There are no solutions for %d.\n",N);

}
int main(){
	#ifndef ONLINE_JUDGE
		freopen("in","rt",stdin);
	#endif
    go(0,5,0);
    total = SZ( vt );

    while( scanf("%d",&N)==1 ){
        if( N==0 )break;
        doit();
    }

return 0;
}
